class Score extends egret.DisplayObjectContainer {
    private txt:egret.Bitmap;
    public totalScore:egret.BitmapText;
    public pershowScore:egret.BitmapText;
    public meme:egret.BitmapText;
    
    public constructor(){
        super();

        //沙漏
        this.txt = new egret.Bitmap();
        this.txt.texture = RES.getRes("score_txt_png");        
        this.txt.height = 60;
        this.txt.width = this.txt.height*(263/105);
        this.txt.x = 0;
        this.addChild(this.txt);

        // 分数 0:
        RES.getResByUrl("resource/assets/score_font.fnt" , this.showScore , this,RES.ResourceItem.TYPE_FONT);

        //每次得分，头顶飘过
        RES.getResByUrl("resource/assets/time_chance.fnt" , this.perShowScore , this,RES.ResourceItem.TYPE_FONT);

        // 表情包：开心or不开心
        RES.getResByUrl("resource/assets/emotion.fnt" , this.emotion , this,RES.ResourceItem.TYPE_FONT);

    }


    public showScore(font:egret.BitmapFont){
        // 30s倒数：
        this.totalScore = new egret.BitmapText();
        this.totalScore.font = font;
        this.totalScore.scaleX = 0.6;
        this.totalScore.scaleY = 0.6;
        this.totalScore.x = this.txt.width + 5;
        this.totalScore.y = 6;
        this.addChild(this.totalScore);
        this.totalScore.text = "0";
   }

   // 每次获得分数，头顶飘分数
    public perShowScore(font:egret.BitmapFont){
        this.pershowScore = new egret.BitmapText();
        this.pershowScore.font = font;
        this.pershowScore.scaleX = 1;
        this.pershowScore.scaleY = 1;
        this.pershowScore.y = 200;
    }

    // 不同石头分数不同、速度不同
    public eachScore(i:number):Array<number>{
        let score:number,
            spe:number;
        let result:Array<number> = [];
        if(i <= 1){
            score = 10;
            spe = 3;
        }else if(i <= 4){
            score = 8;
            spe = 20;
        }else if(i <= 7){
            score = 5;
            spe = 3;
        }else if(i <= 9){
            score = 3;
            spe = 20;
        }else if(i <= 10){
            score = 10;
            spe = 3;
        }else if(i <= 11){
            score = -5;
            spe = 3;
        }
        result = [score , spe]
        return result;
    }

    // 开心或不开心状态
    public emotion(font:egret.BitmapFont){       
        this.meme = new egret.BitmapText();
        this.meme.font = font;
        this.meme.scaleX = 0.5;
        this.meme.scaleY = 0.5;
        this.meme.y = 160;
    }

}